/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package stock;

import misc.JsonEncodable;
import net.sourceforge.javajson.JsonObject;

/**
 * 
 * @author Fredrik
 */
public class NetfondsSale implements JsonEncodable, Comparable<NetfondsSale> {

    private final long time;
    private String name;
    private final double price;
    private long amount;
    private final String seller;
    private final String buyer;

    public NetfondsSale(long time, String name, double price, long amount, String buyer, String seller) {
        this.time = time;
        this.name = name;
        this.price = price;
        this.amount = amount;
        this.seller = seller;
        this.buyer = buyer;
    }

    public long getTime() {
        return time;
    }

    public String getName() {
        return name;
    }

    public double getPrice() {
        return price;
    }

    public long getAmount() {
        return amount;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void addAmount(long amount) {
        this.amount += amount;
    }

    public String getSeller() {
		return seller;
	}

	public String getBuyer() {
		return buyer;
	}

	@Override
    public String toString() {
        return "name=" + name + "&time=" + time + "&price=" + price
                + "&amount=" + amount + "&buyer=" + buyer + "&seller=" + seller;
    }

    @Override
    public void putJSON(JsonObject obj) {
        obj.put("time", time);
        obj.put("name", name);
        obj.put("price", price);
        obj.put("amount", amount);
        obj.put("buyer", buyer);
        obj.put("seller", seller);
    }

    @Override
    public boolean equals(Object other) {
        return ((NetfondsSale) other).time == time;
        // return ((Sale) other).name.equals(name);
    }

    @Override
    public int compareTo(NetfondsSale t2) {
        return Long.compare(time, t2.getTime());
    }
}
